package com.mylib.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.mylib.libcore.AppContext;
import com.mylib.libcore.R;
import com.mylib.libcore.bean.EveryDayCoin;
import com.mylib.libcore.config.CoinTypeEnum;
import com.mylib.libcore.utils.ActivityUtil;


/**
 * @author Administrator
 * @date 2019/12/20-9:38
 * @description CustomCoinView-自定义金币
 **/
public class CustomItemCoinView extends LinearLayout {
    private Context mContext;
    private View mView;
    //接口回调
    public ViewClink viewClink;
    public interface ViewClink {
        void itemClink(View view,String jsonString, String coinNumber);
    }
    public void SetViewClink(ViewClink viewClink){
        this.viewClink = viewClink;
    }

    public CustomItemCoinView(Context context) {
        this(context, null);
    }

    public CustomItemCoinView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomItemCoinView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context, attrs);
    }


    private void init(Context context, AttributeSet attrs) {
        mContext = context;
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mView = inflater.inflate(R.layout.item_main_glod_coin_view, this, true);
       // relativeLayout = (RelativeLayout) mView.findViewById(R.id.rl_coin_view);
    }

    /**
     * 随机出现金币
     * coinNumber 金币数量
     */
    public void initCoinView(CoinTypeEnum type, String coin) {
         final TextView item1 = mView.findViewById(R.id.tv_gold_num);
        final TextView item2 = mView.findViewById(R.id.tv_gold_num_text);
        item1.setBackground(mContext.getResources().getDrawable(R.drawable.img_main_coin_gold));//设置图片
        item1.setTextColor(mContext.getResources().getColor(R.color.white));
        item1.setText(coin+"");
        item2.setText(getKeyCoinTitle(type)+"");
    }
    public String  getKeyCoinTitle(CoinTypeEnum type){
        String title ="";
         switch (type){
            case LOGIN_COIN:
                title="今日登录";
                break;
            case ON_LINE_COIN:
                title="在线奖励";
                break;
            case DK_COIN:
                title="打卡奖励";
                break;
            case SIGN_COIN:
                title="签到奖励";
                break;
            case LL_COIN:
                title="浏览奖励";
                break;
            case GAME_COIN:
                title="游戏奖励";
                break;
            case NOVEL_COIN:
                title="小说奖励";
                break;
            case TZ_COIN:
                title="挑战奖励";
                break;
            case CG_COIN:
                title="闯关奖励";
                break;
            case NEWS_COIN:
                title="资讯奖励";
                break;
            case WEATHER_COIN:
                title="天气奖励";
                break;
            case VIDEO_COIN:
                title="视频奖励";
                break;
            case BK_COIN:
                title="浏览百科";
                break;
            case INVITE_COIN:
                title="邀请奖励";
                break;
            case ZS_COIN:
                title="知识宝库";
                break;
            case LOTTERY_COIN:
                title="参与抽奖";
                break;
            case WW_COIN:
                title="微文奖励";
                break;
            case RANK_COIN:
                title="排行奖励";
                break;
        }
        return title;
     }
}
